<?php


namespace app\admin\model;

class ProjectsLayoutDrawingsDetail extends Base
{
    /**
     * Desc: 排料图纸关联明细
     * User: 苏鹏
     * Date: 2023/11/2
     * Time: 13:36
     * @return void
     */
    public function layoutDarwReDetail(array $data, int $layout_draw_id, bool $is_update = false)
    {
        //修改时先清空关联关系
        if($is_update == true){
            $this->where('layout_draw_id', '=', $layout_draw_id)->delete();
        }

        if(!empty($data))
        {
            $save_data = [];
            foreach($data as $k=>$v)
            {
                $save_data[] = [
                    'identifier' => $v['identifier'],
                    'number' => intval($v['number']),
                    'total_number' => intval($v['total_number']),
                    'layout_draw_id' => $layout_draw_id
                ];
            }
            $this->saveAll($save_data);
        }

    }
}